package com.pactera.madp.cp.controller.oms.keyword;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pactera.madp.common.core.util.R;
import com.pactera.madp.common.log.annotation.SysLog;
import com.pactera.madp.cp.api.dto.wxGZH.KeywordAddDTO;
import com.pactera.madp.cp.api.dto.wxGZH.KeywordUpdateDTO;
import com.pactera.madp.cp.api.vo.wxgzh.QueryKeywordVO;
import com.pactera.madp.cp.service.WxGzhKeywordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @date: 2021/8/23 17:01
 * @description:
 */
@RestController
@AllArgsConstructor
@RequestMapping("/keywordmanagment")
@Api(value = "keywordmanagment", tags = "关键词管理")
public class KeywordController {

    @Resource
    private WxGzhKeywordService keywordService;

    @SysLog("新建关键词")
    @PostMapping
    @ApiOperation(value = "新建关键词")
    public R savaKeyword(@RequestBody KeywordAddDTO dto){return R.ok(keywordService.saveKeyword(dto));}

    @SysLog("修改关键词")
    @PutMapping
    @ApiOperation(value = "修改关键词")
    public R updateKeyword(@RequestBody KeywordUpdateDTO dto){return R.ok(keywordService.updateKeyword(dto));}

    @SysLog("删除关键词")
    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除关键词")
    public R deleteKeyword(@PathVariable Integer id){return R.ok(keywordService.deleteKeyword(id));}

    @GetMapping("/pageQuery")
    @ApiOperation(value = "分页查询关键词列表")
    public R<Page<List<QueryKeywordVO>>> pageQuery(Page page, String problem){return keywordService.pageQuery(page,problem);}

}
